package com.lib.base.utils

import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkInfo

/**
 * @author 网络辅助类
 * @desc 类说明：
 */

object NetUtils {
    fun isConnected(context: Context): Boolean {
        val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
        val info = cm.activeNetworkInfo

        if (null != info && info.isConnected) {
            if (info.detailedState == NetworkInfo.DetailedState.CONNECTED) {
                return true
            }
        }
        return false
    }
}